package eg.backend.repository;

import java.util.List;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import eg.backend.base.PermissionType;
import eg.backend.base.repository.EntityRepository;
import eg.backend.domain.Dimension;
import eg.backend.domain.User;

@Transactional(propagation = Propagation.SUPPORTS)
public interface DimensionRepository extends EntityRepository<Dimension, String> {
	List<Dimension> findUserRootDimensions(String user);
	
	List<Dimension> findSystemRootDimensions();
	
	@Transactional(propagation = Propagation.REQUIRES_NEW)
	List<Dimension> findAvailByParent(String parent, String user, String userName);
	
	List<Dimension> findSharedDimensions(List<PermissionType> permissions, User user);
	List<Dimension> findSharedDimensionsByParent(Dimension parent, List<PermissionType> permissions, User user);
	
	List<Dimension> findDescendants(String position, String rootDimension, String userId);
	List<String> findDescendantIds(String position, String rootDimension, String userId);
	
	void deleteRootDimension(String rootDimension);
	
	List<String> findSystemCategory(String position);
	List<String> findUserCategory(String user, String position);
	
	Dimension eagerGet(String key);
	List<Dimension> find(String user);
	
	void deleteById(String id);
}